package com.bieyang.anjia.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.bieyang.anjia.R;
import com.bieyang.anjia.net.NetManager;
import com.bieyang.anjia.utils.Constants;
import com.bieyang.anjia.utils.SharedPrefsUtil;
import com.bieyang.anjia.utils.Show;

public class AcFankui extends BaseFlingActivity implements OnClickListener {
	EditText etContent;
	Context con;
	 Button btnCommit;
	
	

	private Handler handler = new Handler() {

		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case Constants.COMMIT_SUGGESTION_SUCESS:
				Show.toast(con, R.string.tip_fankui_ok);
				btnCommit.setEnabled(false);
				finish();
				break;
			case Constants.COMMIT_SUGGESTION_FAIL:
				Show.toast(con, R.string.tip_commit_fail);
				break;

			default:
				break;
			}
		};

	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_fankui);
		con = AcFankui.this;

		findViewById(R.id.btnBack).setOnClickListener(this);
		   btnCommit= (Button) findViewById(R.id.btnCommit);
		 btnCommit.setOnClickListener(this);

		etContent = (EditText) findViewById(R.id.etFankui);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnBack:
			finish();
			break;

		case R.id.btnCommit:
			String memberId = SharedPrefsUtil.getStringValue(App.mContext, "memberId", "");
			String content = etContent.getText().toString().trim();
			if("".equals(content)){
				Show.toast(con, R.string.input_not_empty);
				return;
			}

			App.netManager.backSuggestion(memberId, content, handler);

			break;
		}
	}

}
